/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable no-unused-expressions */
import { App, Directive, DirectiveBinding } from 'vue'

// 权限库
const permission = new Set(['1000', '10', '300'])

const authDirective: Directive = {
  mounted: (el: Element, binging: DirectiveBinding<any>) => {
    const value = binging.value
    if (!value) return
    !permission.has(value) && el.parentNode?.removeChild(el)
  }
}

const install = (app: App) => {
  app.directive('auth', authDirective)
}
export default install
